/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gob.fonafe.dao.impl.stored;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import oracle.jdbc.OracleTypes;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.StoredProcedure;
import pe.gob.fonafe.domain.BienSubastaBean;

/**
 *
 * @author czela
 */
public class ListarBienesBySubastaSP extends StoredProcedure{

    private static final String PROC_PARAM="USERFINAL.P_BIENES_SUBASTA";


    public ListarBienesBySubastaSP(DataSource ds) {
        super(ds, PROC_PARAM);

        declareParameter(new SqlParameter("P_ID_SUBASTA", Types.VARCHAR));
        declareParameter(new SqlOutParameter("cCURSOR", OracleTypes.CURSOR,new ListarBienesRowMapper()));
        compile();
    }


    public Map execute(String idSubasta){
        Map inputs = new HashMap();
        inputs.put("P_ID_SUBASTA", idSubasta);
        return super.execute(inputs);
    }



    private static class ListarBienesRowMapper implements RowMapper<BienSubastaBean>{

        public BienSubastaBean mapRow(ResultSet rs, int rowNum) throws SQLException {
            BienSubastaBean bean = new BienSubastaBean();
            bean.setId(rs.getString("ID"));
            bean.setNombre(rs.getString("nombre"));
            bean.setUbigeo(rs.getString("ubigeo"));
            bean.setDireccion(rs.getString("direccion"));
            bean.setTipoMoneda(rs.getString("TIPO_MONEDA"));
            bean.setPrecio(rs.getString("PRECIO"));
            return bean;
        }


    }




}
